package formBean;

import java.util.ArrayList;
import java.util.List;

import org.mybeans.form.FormBean;

public class AddBookmarksForm extends FormBean{

	private String url = "";
	private String comment = "";
	
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getComment() {
		return comment;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	
	public List<String> getValidationErrors() {
		List<String> errors = new ArrayList<String>();
		
		if (url == null || url.length() == 0) {
			errors.add("URL is required");
		}else{
			if (url.contains(">") || url.contains("<") || url.contains("'") || url.contains("\"")) {
				errors.add("Invalid URL format");
			}	
		}

		if (comment == null || comment.length() == 0) {
			errors.add("comment is required");
		}else{
			if (comment.contains(">") || comment.contains("<") || comment.contains("'") || comment.contains("\"") || comment.contains("\\") || comment.contains("/")) {
				errors.add("Comment URL format");
			}
		}
		return errors;
	}
}
